package com.snow.utils;

import io.swagger.annotations.Api;
import lombok.Getter;
import lombok.Setter;

/**
 * @Description:
 * 返回的参数封装类
 * @author: snow
 * @Date: 2020-01-22
 **/
@Setter
@Getter
public class ApiResponse <T> {
    private static final String CODE_SUCCESS = "success";
    private static final String CODE_FAIL = "fail";
    private String code;
    private T data;
    private String msg;
    public ApiResponse(){

    }
    public ApiResponse(String code){
        this.code = code;
    }
    public ApiResponse(String code, T data){
        this.code = code;
        this.data = data;
    }
    public ApiResponse(String code,String msg){
        this.code = code;
        this.msg= msg;
    }
    public static ApiResponse success(){
        return new ApiResponse(CODE_SUCCESS);
    }
    public static ApiResponse success(Object data){
        return new ApiResponse(CODE_SUCCESS,data);
    }
    public static ApiResponse fail(String aNull){
        return new ApiResponse(CODE_FAIL);
    }
    public static ApiResponse withCode(String errorCode){
        return new ApiResponse(errorCode);
    }


}
